#include<iostream>
#include<string>
#include <vector>
#include <stack>

using namespace std;

bool gobang(string arr[])
{
    for(int i = 0; i < 20; ++i){
        for(int j = 0; j < 20; ++j){
            if(arr[i][j] == '.')
                continue;
            int right = 1, right_down = 1, down = 1, left_down = 1;
            for(int k = 1; k < 5; ++k){
                //向右
                if(j<16 && arr[i][j] == arr[i][j+k])
                    ++right;
                if(i<16 && j<16 && arr[i][j] == arr[i+k][j+k])
                    ++right_down;
                if(i<16 && arr[i][j] == arr[i+k][j])
                    ++down;
                if(j>3 && i<16 && arr[i][j] == arr[i+k][j-k])
                    ++left_down;
            }
            if(right == 5 || right_down == 5 || down == 5
               || left_down == 5)
                return true;
        }
    }
    return false;
}

void Test1(){
    string arr[20];
    while(cin>>arr[0]){
        for(int i = 1; i < 20; ++i)
            cin>>arr[i];
        if(gobang(arr))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> _st;
        for(auto & token : tokens){
            if(token == "+"
               || token == "-"
               || token == "*"
               || token == "/"){
                long long left = _st.top();
                _st.pop();
                long long right = _st.top();
                _st.pop();
                if(token == "+")
                    _st.push(left + right);
                if(token == "-")
                    _st.push(right - left);
                if(token == "*")
                    _st.push(left * right);
                if(token == "/")
                    _st.push(right / left);
            }
            else
                _st.push(stoi(token));
        }
        return _st.top();
    }
};

void Test2(){
    vector<string> tokens;
    string token;
    int n = 0;
    while(cin >> n){
        for (int i = 0; i < n; ++i) {
            cin >> token;
            if(token == "#")
                break;
            else
                tokens.push_back(token);
        }
        Solution s;
        cout<<s.evalRPN(tokens)<<endl;
    }
}

int main() {
    Test2();
    return 0;
}
